<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width" />
  <title>HELLO, AMAP!</title>
  <style>
			html,
			body,
			#container {
				width: 100%;
				height: 100%;
			}
		</style>


</head>

<body>
<!--<button onclick="onLocation(12,22)">测试</button>-->
<div id="container"></div>

<script type="text/javascript">
			window._AMapSecurityConfig = {
				securityJsCode: "a87006994c7de96ee7a4564fd85da550",
			};
		</script>
<script src="https://webapi.amap.com/maps?v=1.4.15&key=a9869ed4cec0ed367bf9c7de2b4ea895"></script>
<script>
		var map = new AMap.Map("container", {
		   zoom: 15, //级别
		   center: [116.397428, 39.90923], //中心点坐标
		 })
		window.onload = async function () {
		    if(window.hoursend) {
		      window.hoursend.getLocation("onLocation")
		    }
		 }
		  function onLocation(lon, lat) {
			  window.hoursend.alert("获取到当前位置"+lon)

		    map.setZoomAndCenter(18, [106.558036,29.562326])
			map.plugin(['AMap.PlaceSearch'], function() {
			    var PlaceSearchOptions = { //设置PlaceSearch属性
			        pageSize: 10, //每页结果数,默认10
			        pageIndex: 1, //请求页码，默认1
			        extensions: "base" //返回信息详略，默认为base（基本信息）
			    };
			    var MSearch = new AMap.PlaceSearch(PlaceSearchOptions); //构造PlaceSearch类
			    AMap.event.addListener(MSearch, "complete", (result)=>{
					console.info(JSON.stringify(result))
					window.hoursend.receiveData(JSON.stringify(result))
				}); //返回结果
			    MSearch.searchNearBy('地点',new AMap.LngLat(106.558036,29.562326)); //关键字查询
			});
		  }
		</script>

</body>
</html>
